# Audio This document provides a concise guide for operating the Linux audio system on M1/L1 development boards. The system adopts a dual-layer audio architecture of ALSA + PulseAudio, delivering a complete audio solution from the underlying drivers up to the application layer. The M1/L1 development board's audio hardware includes 2 input channels and 2 output channels, realized via the onboard SH1.0-4P connector, onboard MEMS devices, and reserved test points on the board. Please ensure correct hardware connections before operation. | **Channel Type** | **Channel Name** | **Hardware Location** | **Description** | | --- | --- | --- | --- | | Input | Onboard MIC | MEMS microphone on the mainboard | Built‑in silicon microphone; default recording input source; no external connection required. | | Input & Output | Headset | SH1.0‑4P connector | External headset with microphone. | | Output | SPK (Speaker) | Reserved test points | Drives high‑power external speaker (requires an external amplifier; direct connection to speaker results in low volume). | | Output | EAR (Earpiece) | Reserved test points | Drives low‑power earpiece / headphone. | The system provides a set of standard audio configuration and debugging commands for common operations such as device inspection, recording, playback, and volume control. With this document, you can quickly locate and resolve most audio‑related issues without diving into complex configurations. ```{image} images/image_EFQpbgnUkoEkqmxuPC8cx3urn2V.webp :width: 1280px :height: 1000px :align: center ``` ```{image} images/image_U0CLb10iHoaEj6xohNecLY8cnVc.webp :width: 484px :height: 591px :align: center ``` ## Check Sound Card Information You can check the loaded sound cards and PCM devices on the system with the following commands: - View the list of sound cards: ```shell cat /proc/asound/cards ``` ```{image} images/image_HCRJbFatGocjm1xxcLLcj412nEf.webp :width: 675px :height: 86px ``` - View the list of allocated PCM streams: ```shell cat /proc/asound/pcm ``` ```{image} images/image_PswEb0zZ4oxAD0xLtVEcHz7Dnuf.webp :width: 676px :height: 362px ``` > Note: If the system does not detect any sound card information or PCM streams, neither ALSA nor PulseAudio will function properly. ## ALSA Architecture ### ALSA Overview ALSA (Advanced Linux Sound Architecture) is the underlying audio framework and driver core of the Linux system. It directly manages and controls the audio hardware of the computer. On one hand, it provides native drivers for sound cards, enabling direct read/write access to physical audio channels (such as external microphones, headphones, and speakers). On the other hand, it offers standardized API interfaces for applications to perform the most basic audio capture and playback. ALSA is the foundation upon which all higher-level audio services (such as PulseAudio) are built. ### Audio Recording Under the **Linux** system, confirm that the smart main control board's audio configuration file `/etc/backend_conf.xml` is correctly configured (the system is configured by default): ```xml ``` In the **Android** system, the above audio configuration takes effect by default and requires no additional modification. #### Onboard Microphone Recording ##### Recording under Linux Before recording, you need to stop the **PulseAudio** service: ```shell systemctl stop pulseaudio tinymix "TX DEC0 MUX" "SWR_MIC" tinymix "ADC2 ChMap" "SWRM_TX2_CH1" tinymix "TX SMIC MUX0" "SWR_MIC4" tinymix "TX_AIF1_CAP Mixer DEC0" "1" tinymix "ADC2_MIXER Switch" "1" tinymix "ADC2 MUX" "INP3" tinymix 'TX_AIF1_CAP Mixer DEC2' '1' agmcap /data/testMic3.wav -D 100 -d 101 -c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3" ``` ##### Recording under Android ```shell tinymix "TX DEC0 MUX" "SWR_MIC" tinymix "ADC2 ChMap" "SWRM_TX2_CH1" tinymix "TX SMIC MUX0" "SWR_MIC4" tinymix "TX_AIF1_CAP Mixer DEC0" "1" tinymix "ADC2_MIXER Switch" "1" tinymix "ADC2 MUX" "INP3" tinymix 'TX_AIF1_CAP Mixer DEC2' '1' agmcap ./testMic3.wav -D 100 -d 101 -c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3" ``` ##### To stop recording, press `Ctrl + Z`. ```{image} images/image_GhN1bqLHIoJEUXxwjHPcbXz6nac.webp :width: 773px :height: 367px ``` #### Headset (External) Microphone Recording ##### Recording under Linux ```shell systemctl stop pulseaudio tinymix "TX DEC0 MUX" "SWR_MIC" tinymix "TX SMIC MUX0" "SWR_MIC5" tinymix "DEC0_BCS Switch" "1" tinymix "TX_AIF1_CAP Mixer DEC0" "1" tinymix "ADC2 ChMap" "SWRM_TX2_CH2" tinymix "MBHC ChMap" "SWRM_TX3_CH3" tinymix "ADC2_MIXER Switch" "1" tinymix "ADC2 MUX" "INP2" tinymix "BCS Channel" "CH10" agmcap /data/rec2.wav -D 100 -d 101 -c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3" ``` ##### Recording under Android ```shell tinymix "TX DEC0 MUX" "SWR_MIC" tinymix "TX SMIC MUX0" "SWR_MIC5" tinymix "DEC0_BCS Switch" "1" tinymix "TX_AIF1_CAP Mixer DEC0" "1" tinymix "ADC2 ChMap" "SWRM_TX2_CH2" tinymix "MBHC ChMap" "SWRM_TX3_CH3" tinymix "ADC2_MIXER Switch" "1" tinymix "ADC2 MUX" "INP2" tinymix "BCS Channel" "CH10" agmcap ./rec2.wav -D 100 -d 101 –c 1 -r 48000 -i "CODEC_DMA-LPAIF_RXTX-TX-3" ``` Note: Ensure you have write permissions in the current directory before executing the recording command. ```{image} images/image_LKVBbIBQFoazGXxFo5ZcyJCDnZd.webp :width: 898px :height: 644px ``` ### Audio Playback The onboard speaker is not soldered; please use the external headphone channel for playback. #### Headphone Playback ##### Playback under Linux (3.5mm headphone) ```shell systemctl stop pulseaudio tinymix "RX_MACRO RX0 MUX" "AIF1_PB" tinymix "RX_MACRO RX1 MUX" "AIF1_PB" tinymix "RX INT0_1 MIX1 INP0" "RX0" tinymix "RX INT1_1 MIX1 INP0" "RX1" tinymix "RX INT0 DEM MUX" "CLSH_DSM_OUT" tinymix "RX INT1 DEM MUX" "CLSH_DSM_OUT" tinymix "RX_COMP1 Switch" "1" tinymix "RX_COMP2 Switch" "1" tinymix "HPHL Switch" "1" tinymix "HPHR Switch" "1" tinymix "HPHL_RDAC Switch" "1" tinymix "HPHR_RDAC Switch" "1" agmplay /data/vvdn_ring.wav -D 100 -d 100 -i CODEC_DMA-LPAIF_RXTX-RX-0 -dkv 0xA2000002 ``` ##### Playback under Android (3.5mm headphone) ```shell adb root adb shell cd /data/local/tmp tinymix "RX_MACRO RX0 MUX" "AIF1_PB" tinymix "RX_MACRO RX1 MUX" "AIF1_PB" tinymix "RX INT0_1 MIX1 INP0" "RX0" tinymix "RX INT1_1 MIX1 INP0" "RX1" tinymix "RX INT0 DEM MUX" "CLSH_DSM_OUT" tinymix "RX INT1 DEM MUX" "CLSH_DSM_OUT" tinymix "RX_COMP1 Switch" "1" tinymix "RX_COMP2 Switch" "1" tinymix "HPHL_RDAC Switch" "1" tinymix "HPHR_RDAC Switch" "1" agmplay ./vvdn_ring.wav -D 100 -d 100 -i CODEC_DMA-LPAIF_RXTX-RX-0 -dkv 0xA2000002 ``` ```{image} images/image_YDDOb9LLSoTNo2x1YjbcBLotnjc.webp :width: 791px :height: 374px ``` ## PulseAudio Architecture ### PulseAudio Overview PulseAudio is a cross-platform, network-capable audio service. It receives audio input from one or more sources (processes or input devices), and then redirects the audio to one or more sinks (sound cards, remote network PulseAudio services, or other processes). It interacts with the lowest-level ALSA and provides a unified interface for applications, thereby enabling advanced features such as multi-channel audio mixing and audio forwarding. #### Device Inspection and Management **1. View Available Output Devices (Sinks)** - To view the currently available audio output devices and their detailed information, use the following command. - This command lists the index and name of all available sinks (output devices). Example output: ```bash sh-5.2# pactl list short sinks ``` - To obtain more detailed device information, use: ```bash sh-5.2# pactl list sinks ``` **2. View Input Devices (Sources)** - Similarly, you can view audio input devices (such as microphones) with the following command: ```bash sh-5.2# pactl list short sources ``` - To obtain more detailed device information, use: ```bash sh-5.2# pactl list sources ``` #### Recording **1. Onboard Microphone Recording** ```bash pactl set-source-port 4 speaker-mic pactl -d 4 --file-format=wav output.wav ``` **2. Headset Microphone Recording** ```bash pactl set-source-port 4 headset-mic parec -d 4 --file-format=wav output1.wav ``` #### Playback **1. Speaker Playback** ```bash pactl set-sink-port 1 speaker paplay output.wav ``` **2. Headphone Playback** ```bash pactl set-sink-port 1 headset paplay output1.wav ``` ### Advanced Features #### Sink Explanation ```bash root@qcm6490-idp:~# pactl list sinks short 0 low-latency0 module-pal-card.c s16le 2ch 48000Hz SUSPENDED 1 deep-buffer0 module-pal-card.c s16le 2ch 32000Hz SUSPENDED 2 offload0 module-pal-card.c s16le 2ch 48000Hz SUSPENDED 3 voip-rx0 module-pal-card.c s16le 2ch 48000Hz SUSPENDED root@qcm6490-idp:~# ``` **1.low-latency0** - Purpose: Used for real-time audio playback such as music, games, notifications, etc., requiring ultra‑low latency. - Characteristics: - Extremely low latency, suitable for latency‑sensitive applications. - Supports PCM format (uncompressed audio). - Works with both speaker and headset outputs. **2.deep-buffer0** - Purpose: Used for audio playback that benefits from a larger buffer, e.g., streaming media, internet radio. The larger buffer reduces stuttering. - Characteristics: - Higher latency but more stable audio, ideal for unstable network conditions. - Works with both speaker and headset outputs. - **3.offload0** - Purpose: Used for hardware‑offloaded playback of compressed audio (e.g., MP3, AAC). The hardware directly decodes the audio, saving CPU resources. - Characteristics: - Supports only compressed formats (e.g., MPEG, AAC); does not support PCM. - Suitable for long‑duration playback of compressed audio (e.g., music players). **4.voip-rx0** - Purpose: Dedicated to audio reception for VoIP calls (e.g., internet telephony, video conferencing). - Characteristics: - Optimised for low latency and echo suppression in voice calls. - Activated automatically only during VoIP applications (such as Skype, Zoom); regular audio playback does not use this sink. #### Source Explanation ```bash sh-5.2# pactl list sources short 1 low-latency0.monitor module-qal-card.c s16le 2ch 48000Hz SUSPENDED 2 deep-buffer0.monitor module-qal-card.c s16le 2ch 48000Hz SUSPENDED 3 offload0.monitor module-qal-card.c s16le 2ch 48000Hz SUSPENDED 4 regular0 module-qal-card.c s16le 1ch 48000Hz SUSPENDED ``` **1.low-latency0.monitor** - Purpose: Used for real‑time recording, such as capturing game sounds, music player output, etc. - Characteristics: - Extremely low latency, ideal for real‑time monitoring of audio output. **2.deep-buffer0.monitor** - Purpose: Used for long‑duration recording, e.g., streaming media, internet radio. - Characteristics: - Higher latency but more stable audio, suitable for unstable network environments. **3.offload0.monitor** - Purpose: Used to record the audio output of the `offload0` sink – i.e., captures hardware‑decoded compressed audio (e.g., MP3, AAC). - Characteristics: - Activated only during playback of compressed audio. - Suitable for long‑duration recording of compressed audio. **4.voip-rx0.monitor** - Purpose: Used for recording the remote party's voice during VoIP calls or video conferences. - Characteristics: - Suitable for capturing the remote party's audio in internet telephony or video conferencing applications. **5.regular0** - Purpose: Used for direct recording from microphone or line‑in input. - Characteristics: - General‑purpose audio input source, applicable to most recording scenarios. **6.voip-tx0** - Purpose: Used for audio transmission in VoIP calls – i.e., records your microphone input for internet telephony. - Characteristics: - Optimised for voice call quality and latency. ## Cellular Voice Call In the Weston environment, there is no graphical dialing interface. Call control is performed through the `qlril-api-test` command‑line tool. This tool supports event registration, dialing, answering, and hanging up calls. Audio routing during a call still needs to be switched via PulseAudio commands (`pactl`). ### Test Preparation and Initialization Ensure that the SIM card is correctly inserted and the module has registered on the network. Send the AT command `AT$QCSIMAPP=?` to check the network connection status: > AT$QCSIMAPP=? > $QCSIMAPP: 0,"SUB1","L" # Network connected > $QCSIMAPP: 1,"SUB2","No Service" Before dialing or answering, use `pactl` to switch the audio channel to the desired device. Example: ```plaintext #List current audio devices pactl list short sinks pactl list short sources # Switch to headset channel pactl set-source-port 4 headset-mic pactl set-sink-port 1 headset # Switch to onboard MIC recording + headset playback pactl set-source-port 4 speaker-mic pactl set-sink-port 1 headset ``` Open a terminal and execute the following command to start the `qlril-api-test` program: ```plaintext qlril-api-test ``` ### Configure Event Listening In order to receive incoming call and call status events, perform the following settings (the numbers below correspond to the command indices within the program): ```plaintext # Enter 10 to enable the event listener > 10 # Enter 12, then enter the start value 1000, then the end value 1070, to enable registered event listening # (The end value can be adjusted according to the maximum value actually returned; new events may be added in SW) > 12 > 1000 > 1070 # Enter 13 to suppress message events with IDs in the range 1009~1009 (adjust as needed) > 13 > 1009 > 1009 ``` ### Answer an Incoming Call (Terminated Call Test) When the auxiliary device calls the test device, the `qlril-api-test` window will report an incoming call event, similar to: ```{image} images/image_ZnBdbSjFioGYP1x8afIc2ALnn1V.webp :width: 524px :height: 510px ``` Then perform the following to answer: ```plaintext #Enter 44 to answer the incoming call > 44 ``` After answering, the call should be established. If there is "no sound during the call", please check whether the audio routing is correct. ### Hang Up a Call After the call ends, execute: ```plaintext # Enter 43, then select 1 (hang up the current call) > 43 > 1 ``` The call will then be hung up, and the interface should indicate a successful hang‑up. ### Dial Out (Originating Call Test) To initiate a call, use the following command (assuming the number is 10086): ```plaintext # Enter 43, then enter the phone number > 43 > 10086 ``` After dialing, the system will place the call, and the other party can answer to start the conversation. ## Troubleshooting [电子表格] ## Resources and Support - [ALSA]() - [tinyalsa]()